home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / antvirus / vchk804.lha / Virus_Checker / ARexx / Virus_Checker7.dopus5
Text File  |  1995-08-27  |  7KB  |  189 lines

  1. /* Virus_Checker7 for Directory Opus 5 and Virus_Checker 7.
  2.    By Leo Davidson ("Nudel", Pot-Noodle/Gods'Gift Utilities)
  3.  
  4. $VER: Virus_Checker7 1.2 (18.8.95)
  5.  
  6.    NOTE: This script _requires_ DOpus v5.11 or above.
  7.  
  8.    If you include the path of a file/dir on the command line, using a {}, only
  9.    this file/dir will be tested. If you omit the {}, the program will check
  10.    all selected files and directories in the SOURCE lister for viruses.
  11.  
  12.    If Virus_Checker's ARexx port is not found, the program will be run for
  13.    you (you should edit the path below). This means the script may fail if
  14.    you give an incorrect path to the Virus_Checker program.
  15.  
  16.    If the Virus_Checker's ARexx port takes over a minute to appear, an error
  17.    requester will appear on the DOpus screen and the script will quit.
  18.  
  19.    If Virus_Checker was running to start with, it will be left running after
  20.    the script has completed. Otherwise, it will be removed from memory.
  21.  
  22.    When a virus is detected a beep will sound and once all files have been
  23.    checked you will get a requester with a list of infected files (including
  24.    the type of virus). It is possible that the requester will fail to
  25.    appear if it becomes too large to fit on the screen. The script will
  26.    detect when this happens and output the results to a shell window instead.
  27.  
  28.    Thanks to John Veldthuis <johnv@tower.actrix.gen.nz> for writting
  29.    Virus_Checker, allowing me access to the VC7 beta versions, and for giving
  30.    me a virus-infected file (!) to test this script with.
  31.  
  32. For a "check selected files for viruses" function, call as:
  33. ------------------------------------------------------------------------------
  34. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql}
  35. ------------------------------------------------------------------------------
  36. Turn off all switches.
  37.  
  38.  
  39. For an "Un-LhA to a directory and check for viruses" function, call as:
  40. ------------------------------------------------------------------------------
  41. AmigaDOS    C:LHA -M x {fu} {d}{ou-}/
  42. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql} {d}{o-}
  43. ------------------------------------------------------------------------------
  44. Switches: Do all files
  45.           Output to window
  46.           Rescan dest
  47.           Window close button
  48.  
  49.    v1.00 -> v1.01 - Some minor tidying up.
  50.                     Now checks to make sure the DOPUS.x port exists.
  51.     v1.02 -> v1.3 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  52.                     Style Guide compliant version numbering and $VER string.
  53.  
  54. */
  55. /*- Path to Virus_Checker command ------------------------------------------*/
  56. Virus_Checker = "DH0:Tools/Harddrive/VirusKillers/Virus_Checker"
  57. /*--------------------------------------------------------------------------*/
  58. options results
  59. options failat 99
  60. signal on syntax;signal on ioerr        /* Error trapping */
  61. parse arg DOpusPort source_handle.0 FilePath
  62. DOpusPort = Strip(DOpusPort,"B",'" ')
  63. source_handle.0 = Strip(source_handle.0,"B",'" ')
  64. FilePath = Strip(FilePath,"B",'" ')
  65.  
  66. If DOpusPort="" THEN Do
  67.     Say "Not correctly called from Directory Opus 5!"
  68.     Say "Load this ARexx script into an editor for more info."
  69.     EXIT
  70.     END
  71. If ~Show("P",DOpusPort) Then Do
  72.     Say DOpusPort "is not a valid port."
  73.     EXIT
  74.     End
  75. Address value DOpusPort
  76.  
  77. Quit_After = "NO"
  78. If ~Show("P","Virus_Checker") Then Do
  79.     Address Command Virus_Checker
  80.     Quit_After = "YES"
  81.     TickTick = Time(M)
  82.     Do While ~Show("P","Virus_Checker")
  83.         IF Time(M) - TickTick > 1 Then Do
  84.             dopus request '"Error loading Virus_Checker!'|| '0a'x ||'Check its command-line in the ARexx script itself." OK'
  85.             EXIT
  86.             END
  87.         END
  88.     END
  89.  
  90. /* If file/dir-path was specified on command line, check it, else
  91.    go through all the selected ones. */
  92.  
  93. BadList = ""
  94. BadNumber = 0
  95.  
  96. /*
  97. lister query source stem source_handle.
  98. IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  99.     dopus request '"You must have a SOURCE lister!" OK'
  100.     EXIT
  101.     End
  102. */
  103.  
  104. If FilePath = "" Then Do
  105.     lister set source_handle.0 busy 1
  106.  
  107.     lister query source_handle.0 numselentries    /* Get info about selected */
  108.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  109.     lister query source_handle.0 path
  110.     Lister_Path = Strip(RESULT,"B",'"')
  111.  
  112.     lister set source_handle.0 progress Lister_NumSelEnt "Checking for viruses..."
  113.  
  114.     Do i=1 to Lister_NumSelEnt
  115.         lister query source_handle.0 abort
  116.         If RESULT=1 Then BREAK
  117.         lister query source_handle.0 firstsel
  118.         Temp_Name = Strip(RESULT,"B",'"')
  119.         lister select source_handle.0 Temp_Name 0
  120.         Temp_Path = Lister_Path || Temp_Name
  121.         lister set source_handle.0 progress name Temp_Name
  122.         lister set source_handle.0 progress count i
  123.         Address "Virus_Checker" "Scan "||Temp_Path
  124.         If VCHECK.0.0 ~= 0 Then Do
  125.             command beep
  126.             Do x=1 to VCHECK.0.0
  127.                 BadNumber = BadNumber + 1
  128.                 BadList = BadList || '0a'x || VCHECK.x.1 ||"  (" || VCHECK.x.2 || ")"
  129.                 END
  130.             END
  131.         END
  132.     lister clear source_handle.0 progress
  133.     End
  134.  
  135. ELSE Do
  136.     lister set source_handle.0 progress "-1" "Checking for viruses..."
  137.     Address "Virus_Checker" "Scan "||FilePath
  138.     If VCHECK.0.0 ~= 0 Then Do
  139.         command beep
  140.         Do x=1 to VCHECK.0.0
  141.             BadNumber = BadNumber + 1
  142.             BadList = BadList || '0a'x || VCHECK.x.1 ||"  (" || VCHECK.x.2 || ")"
  143.             END
  144.         END
  145.     lister clear source_handle.0 progress
  146.     End
  147.  
  148. If BadNumber > 0 Then Do
  149.     If BadNumber = 1 Then
  150.         BadNote = "The following file is infected:"
  151.     Else
  152.         BadNote = "The following files are infected:"
  153.     BadList = "*VIRUS WARNING*" || '0a'x || BadNote || '0a'x || "(Virus name in parenthesis)" || '0a'x || BadList
  154.  
  155.     dopus request '"'||BadList||'" OK'
  156.  
  157. /* As there is only one gadget which returns "RC = 1", when "RC = 0" it means
  158.    that the requester failed to appear. This will happen when the list is too
  159.    long or wide to fit on the screen, which could easily happen with a virus
  160.    which has spread itself to many files!
  161.  
  162.    So, if the requester failed, the output will be sent to a shell window.
  163.    It would be nice to be able to use the user's defined output-window
  164.    size but there is (currently) no way of obtaining this. */
  165.  
  166.     IF RC = 0 Then Do
  167.         dopus request '"*VIRUS WARNING*' || '0a'x || 'List too large for requester' || '0a'x || 'and will be output to a shell..." OK'
  168.         Open(Output_Shell,"CON:0/1/640/200/Virus Warning/CLOSE/WAIT","W")
  169.         WriteLN(Output_Shell,BadList)
  170.         Close(Output_Shell)
  171.         END
  172.     END
  173.  
  174. /*-- Restore the Lister for normal use --------------------------------------*/
  175. syntax:;ioerr:                /* In case of error, jump here */
  176. END_PART_2:
  177.  
  178. lister clear source_handle.0 progress
  179.  
  180. If FilePath = "" Then Do
  181.     lister refresh source_handle.0
  182.     lister set source_handle.0 busy 0
  183.     END
  184.  
  185. END_PART:
  186. If Quit_After = "YES" Then Address "Virus_Checker" QUIT
  187.  
  188. EXIT
  189.